package net.lovesrc.support.service.lock;

import java.util.concurrent.TimeUnit;

public interface DistributedLock {

    String PREFIX = "Lock:";

    /**
     * 锁
     */
    void lock(String key);

    /**
     * 锁，带有超时时间
     */
    boolean lock(String key, long timeout, TimeUnit timeUnit);

    /**
     * 释放锁
     */
    void unlock(String key);

    /**
     * 尝试锁，获取锁返回true, 未获取锁返回false
     */
    boolean tryLock(String key);

}
